#ifndef __HELLOWORLD_SCENE_H__
#define __HELLOWORLD_SCENE_H__

#include "cocos2d.h"

#include "Box2D/Box2D.h"

#include "SimpleAudioEngine.h"

//#include "Object/Attribute.h"

#include "Object/NoteObject.h"
#include "Object/EnemyObject.h"

struct StagePhase
{
	int note;
	int delay;
};

class HelloWorld : public CCLayer
{
private:
	enum Defines
	{
		MOLD_TYPE_MAX = 9
	};

	enum MoldType
	{
		mold_normal,
		mold_move,
		mold_fat,
		mold_twin,
		mold_mini,
		mold_brain,
		mold_block,
		mold_twin_left,
		mold_twin_right
	};

	CCNode* m_enemys;
	CCNode* m_notes;

	CCSize screen_size;

	void UpdateNotes();
	void UpdateEnemys();
	void CrashCheckWithEnemy(CNoteObject* pNote);

public:
    // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
    virtual bool init();

	void update(ccTime dt);

	virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent);
	virtual void ccTouchesBegan(CCSet* pTouches, CCEvent *pEvent);
	virtual void ccTouchesMoved(CCSet* pTouches, CCEvent *pEvent);

	virtual void onEnter();
	virtual void onExit();

	int GetColonPos(char* buffer);
	int CharToNote(char* buffer);
	void InitSound();
	void LoadStagePhase(int stage);
	void LoadStageMap(int stage);

    // there's no 'id' in cpp, so we recommand to return the exactly class pointer
    static cocos2d::CCScene* scene();
    
    // a selector callback
    virtual void menuCloseCallback(CCObject* pSender);

    // implement the "static node()" method manually
    LAYER_NODE_FUNC(HelloWorld);

	int old_x;
	int old_y;
	int origin_x;
	int origin_y;

	CAttribute* m_note_attribute;
	CAttribute* m_mold_attribute[MOLD_TYPE_MAX];

	StagePhase* stage_phase;
	int stage_phase_max;
	int phase;
	float next_time;
	bool note_end;
	bool is_clear;
	bool game_over;
	float game_speed;
};

#endif  // __HELLOWORLD_SCENE_H__